package com.kgc.controller;

import com.kgc.dto.Code;
import com.kgc.dto.Result;
import com.kgc.entity.User;
import com.kgc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: luo
 * @date: 2024/4/9 9:55
 * @Description:
 * @Version: 1.0
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public Result login(@RequestBody User user){
        boolean login = userService.login(user);
        if(login){
            return new Result(true, Code.LOGIN_SUCCESS,"登录成功");
        }
        return new Result(false,Code.LOGIN_ERROR,"登录失败");
    }
}
